package controleur;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

import vue.PanelFooter;
/**
 * 
 * @author Plancq Charlotte, Lanvin Kévin, Darras Raphael
 *
 *
 */
public class ImporterListener implements ActionListener {
	private PanelFooter pf;
	
	public ImporterListener (PanelFooter pf){
		this.pf=pf;
	}
	
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		 JFileChooser chooser = new JFileChooser();
		    FileNameExtensionFilter filter = new FileNameExtensionFilter("BDtheque","bdt");
		    chooser.setFileFilter(filter);
		    int returnVal = chooser.showOpenDialog(pf);
		    if(returnVal == JFileChooser.APPROVE_OPTION) {
		       File fichier=chooser.getSelectedFile();
		       try {
				pf.getAffichageGlobal().getTraitement().importer(fichier);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		    }
	}

}
